﻿function SelectAllCheckBox() {
  var chkblist = document.getElementsByName(_subCheckBoxName);
  if (document.getElementById(_allCheckBoxID).checked) {
    for (var i = 0; i < chkblist.length; i++) {
      chkblist[i].checked = true;
    }
  } else {
    for (var i = 0; i < chkblist.length; i++) {
      chkblist[i].checked = false;
    }
  }
}

function SelectThis() {
  var all = CheckIsSelectedAll();
  if (all) document.getElementById(_allCheckBoxID).checked = true;
}

function CheckIsSelectedAll() {
  var chkblist = document.getElementsByName(_subCheckBoxName);
  var all = true;
  for (var i = 0; i < chkblist.length; i++) {
    if (!chkblist[i].checked) {
      document.getElementById(_allCheckBoxID).checked = false;
      all = false;
      break;
    }
  }
  return all;
}

var _allCheckBoxID, _subCheckBoxName;

function SetCheckBoxProperty(allCheckBoxID, subCheckBoxName) {
  _allCheckBoxID = allCheckBoxID;
  _subCheckBoxName = subCheckBoxName;
}